package service

import (
	"bubble/internal/biz"
	"context"

	pb "bubble/api/bubble/v1"
)

type TodoService struct {
	pb.UnimplementedTodoServer

	//业务逻辑结构体
	uc *biz.TodoUsecase
}

func NewTodoService(uc *biz.TodoUsecase) *TodoService {
	return &TodoService{
		uc: uc,
	}
}

func (s *TodoService) CreateTodo(ctx context.Context, in *pb.CreateTodoRequest) (*pb.CreateTodoReply, error) {
	todo, err := s.uc.CreateTodo(ctx, &biz.Todo{Title: in.Title})
	if err != nil {
		return nil, err
	}
	return &pb.CreateTodoReply{
		Todo: &pb.Todo{
			Id:     todo.Id,
			Title:  todo.Title,
			Status: todo.Status,
		},
	}, nil
}

func (s *TodoService) UpdateTodo(ctx context.Context, req *pb.UpdateTodoRequest) (*pb.UpdateTodoReply, error) {
	return &pb.UpdateTodoReply{}, nil
}
func (s *TodoService) DeleteTodo(ctx context.Context, req *pb.DeleteTodoRequest) (*pb.DeleteTodoReply, error) {
	return &pb.DeleteTodoReply{}, nil
}
func (s *TodoService) GetTodo(ctx context.Context, req *pb.GetTodoRequest) (*pb.GetTodoReply, error) {
	return &pb.GetTodoReply{}, nil
}
func (s *TodoService) ListTodo(ctx context.Context, req *pb.ListTodoRequest) (*pb.ListTodoReply, error) {
	return &pb.ListTodoReply{}, nil
}
